1. Detect the Conflict
When a merge conflict occurs, Git will highlight the areas of the file that have conflicting changes. Open the affected file in your preferred text editor, such as Visual Studio Code or Sublime Text.
2. Understand the Conflict
Inside the file, you’ll see special markers that indicate where the conflict happens:
<<<<< HEAD: Represents the changes from your current branch (the base or "HEAD" branch).<<<<< BRANCH-NAME: Shows the changes from the branch you are merging into your current branch.
3. Fix the Conflict
Edit the file to remove the conflict markers and combine or choose the changes that you want to keep. Be sure to delete the lines with <<<<<, <<<<<, and >>>>> after resolving the conflict. Once satisfied, save the file.
4. Stage the Changes
To stage the file after you’ve resolved the conflict, run this command:
git add FILENAME
5. Commit the Resolved Conflict
Now, commit the changes to finalize the resolution:
git commit -m "Fixed merge conflict"

Comments
Post a Comment